package com.jing.mybroadcastreceiver.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

/*
//静态注册广播
public class MyReceiver extends BroadcastReceiver {
    private static final String TAG = "MyReceiver";
    @Override
    public void onReceive(Context context, Intent intent) {
        String msg = intent.getStringExtra("msg");
        Log.e(TAG, "onReceive: " + msg);
    }
}

 */

//动态注册广播
public class MyReceiver extends BroadcastReceiver {
    private static final String TAG = "MyReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        if ("com.jing.mybroadcastreceiver.myReceiver".equals(intent.getAction())) {
            String msg = intent.getStringExtra("msg");
            Log.e(TAG, "onReceive: " + msg);
        }
    }
}
